package handler

import (
	"context"
	"server/basic/dao"
	"server/basic/pkg"
	"server/basic/proto/order"
	"strconv"
)

type OrderServer struct {
	order.UnimplementedOrderServerServer
}

func (s *OrderServer) OrderAddAdd(_ context.Context, req *order.OrderAddReq) (*order.OrderAddResp, error) {
	add, err := dao.OrderAdd(req)
	if err != nil {
		return nil, err
	}

	pkg.Alipay(strconv.FormatFloat(add.OrderMoney, 'f', 1, 64))
	return &order.OrderAddResp{OrderAddId: int32(add.Id)}, nil
}
